<?php
use app\common\services\UrlServices;

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=750">
    <title>九洲口令，红包百应</title>
    <script type="text/javascript" src="<?=UrlServices::buildWWWUrl('/hongbao/js/vie.js')?>"></script>
    <link rel="stylesheet" href="<?=UrlServices::buildWWWUrl('/hongbao/css/common.css')?>">
    <link rel="stylesheet" href="<?=UrlServices::buildWWWUrl('/hongbao/css/result.css')?>">
</head>
<body>
<div class="container">
    <div class="result">
        <div class="headImg">
            <img src="<?=UrlServices::buildWWWUrl('/hongbao/images/1.jpg')?>" alt="">
        </div>
        <!-- 未中奖 -->
        <div class="not-getprize <?php if ($is_ok):?>dnone<?php else:?><?php endif;?>">
            <span>口令读取失败</span>可以寻求朋友帮助哦
        </div>
        <!-- 中奖 -->
        <div class="prize-name <?php if ($is_ok):?><?php else:?>dnone<?php endif;?>">
            <!-- 钱 -->
            <?php if (explode('_', $info['prize_name'])[0] == 'hongbao'):?>
               <span class="momey "><?=explode('_', $info['prize_name'])[1]?><i>元</i></span>
            <?php elseif (explode('_', $info['prize_name'])[0] == '折扣券'):?>
                <div class="prize">
                    <p>电子礼券</p>
                    <a href="<?=UrlServices::buildMUrl('/activity/my-prize', ['id' => $info['id']])?>">去兑奖</a>
                </div>
            <?php else:?>
                <div class="prize">
                    <p>心意好礼</p>
                    <a href="<?=UrlServices::buildMUrl('/activity/my-prize', ['id' => $info['id']])?>">去兑奖</a>
                </div>
            <?php endif;?>

            <!-- 奖品 -->

        </div>
        <input type="hidden" id="open_id" value="<?=$info['open_id']?>">
        <div class="btn">
            <a href="<?=UrlServices::buildMUrl('/activity/get-prize')?>" class="again <?php if ($is_ok):?>dnone<?php else:?><?php endif;?>"></a>
            <a href="javascript:;" class="see <?php if ($is_ok):?><?php else:?>dnone<?php endif;?>"></a>
            <a href="javascript:void(0);" class="share <?php if ($is_ok && $prize_count !=2):?><?php else:?>dnone<?php endif;?>"></a>
            <p style="font-size: 20px;" class=" <?php if ($is_ok):?><?php else:?>dnone<?php endif;?>">分享至朋友圈，额外获得一次参与游戏机会</p>
        </div>
    </div>

    <div class="foot">
        <a href="<?= UrlServices::buildMUrl('/activity/index') ?>" class="tohome">首页</a>
        <a href="<?=UrlServices::buildMUrl('/activity/prize-list')?>" class="<?php if ($prize_count):?>tomyprize<?php else:?><?php endif;?>" data-num="<?=$prize_count?>" >我的奖品</a>
    </div>
</div>

<div class="share-boom"></div>

<div class="certificate-container">
    <img src="<?=UrlServices::buildWWWUrl('/hongbao/images/certificate1.jpg')?>" alt="">
    <img src="<?=UrlServices::buildWWWUrl('/hongbao/images/certificate2.jpg')?>" class="dnone" alt="">
    <img src="<?=UrlServices::buildWWWUrl('/hongbao/images/certificate3.jpg')?>" class="dnone" alt="">
    <p>长按保存图片</p>
</div>

<script src="<?=UrlServices::buildWWWUrl('/hongbao/js/jquery.min.js')?>"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">
    <?php echo $js_info?>
    var weixin = {
        share: function (option) {
            wx.ready(function () {
                //获取“分享到朋友圈”按钮点击状态及自定义分享内容接口
                wx.onMenuShareTimeline({
                    title: option.Title, // 分享标题
                    link: option.Url, // 分享链接
                    imgUrl: option.Img, // 分享图标
                    success: function (e) {
                        $.ajax({
                            url:'/weixin/activity/add-chance',
                            type:'POST',
                            dataType:'json',
                            data:{
                                open_id:$('#open_id').val()
                            },
                            success:function (res) {
                                if(res.code == 200){
                                    window.location.href = '/weixin/activity/get-prize';
                                }else{
                                    alert(res.msg);
                                    window.location.reload()
                                }
                            }

                        });
                    },
                    cancel: function (e) {
                        if (option.callcancel != undefined) {
                            option.callcancel(e);
                        }
                    }
                });
                //获取“分享给朋友”按钮点击状态及自定义分享内容接口
                wx.onMenuShareAppMessage({
                    title: option.Title, // 分享标题
                    desc: option.Desc, // 分享描述
                    link: option.Url, // 分享链接
                    imgUrl: option.Img, // 分享图标
                    type: '', // 分享类型,music、video或link，不填默认为link
                    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                    success: function (e) {
                        //  window.location.href = "http://qgx-bl.horsevision.cn/weixin?act=qingguo&mod=goodsDetails&id=199";
                        // if (option.callsuccess != undefined) {
                        //     option.callsuccess(e);
                        // }
                    },
                    cancel: function (e) {
                        if (option.callcancel != undefined) {
                            option.callcancel(e);
                        }
                    }
                });
                //获取“分享到QQ”按钮点击状态及自定义分享内容接口
                wx.onMenuShareQQ({
                    title: option.Title, // 分享标题
                    desc: option.Desc, // 分享描述
                    link: option.Url, // 分享链接
                    imgUrl: option.Img, // 分享图标
                    success: function (e) {
                        if (option.callsuccess != undefined) {
                            option.callsuccess(e);
                        }
                    },
                    cancel: function (e) {
                        if (option.callcancel != undefined) {
                            option.callcancel(e);
                        }
                    }
                });
            });
        }
    };
    var shareWord = "口令赢红包，魔系女王季";
    var shareUrl = "http://jiuzhou.horsevision.cn/weixin/activity/index";
    var shareDesc = "我正在参加九洲新世界的口令红包活动，一起玩吧!";
    // var shareDesc = "一封送你的中秋祝福~";
    var shareImg = "http://jiuzhou.horsevision.cn/hongbao/images/1.jpg";
    weixin.share({Title: shareWord, Url: shareUrl, Desc: shareDesc, Img: shareImg});

</script>
<script>
    // 分享
    $(".share").click(function(){
        $(".share-boom").fadeIn();
    })

    $(".share-boom").click(function(){
        $(this).fadeOut();
    })

    // 证书
    $(".see").click(function(){
        var num = Math.round(Math.random()*2+1);
        $(".certificate-container img").addClass("dnone");
        $(".certificate-container img").eq(num).removeClass("dnone");
        $('.certificate-container').fadeIn();
    })

    $('.certificate-container').click(function(){
        $(this).fadeOut();
    })
</script>
</body>
</html>
